package com.jsb.laundry.controller;

import com.jsb.laundry.common.response.BaseRequestParam;
import com.jsb.laundry.common.response.WebResponse;
import com.jsb.laundry.model.entity.TopicCategory;
import com.jsb.laundry.model.entity.TopicContent;
import com.jsb.laundry.service.InformationService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

@Api(tags = {"资讯"})
@RestController
@RequestMapping("/information")
public class InformationController {
    private static final Logger LOGGER = LoggerFactory.getLogger(InformationController.class);

    @Resource
    private InformationService shareService;

    /**
     * 查询话题广场的分类
     *
     * @return
     */
    @ApiOperation(value = "查询话题广场的分类", notes = "查询话题广场的分类", httpMethod = "POST")
    @PostMapping("/findAllCategory")
    public WebResponse<List<TopicCategory>> findAllCategory() {
        LOGGER.info("查看话题广场的分类");

        //业务处理
        List<TopicCategory> returnMsg = new ArrayList() {
            {
                add(new TopicCategory());
                add(new TopicCategory());
                add(new TopicCategory());
            }
        };

        //返回数据格式
        return WebResponse.successData(returnMsg);
    }

    /**
     * 查询话题广场某分类下的话题(topicId)
     *
     * @return
     */
    @ApiOperation(value = "查询话题广场某分类下的话题", notes = "查询分类下的话题", httpMethod = "POST")
    @PostMapping("/findTopicById")
    public WebResponse<List<TopicContent>> findTopicById(@RequestBody TopicCategory laundryTopicCategory) {
        LOGGER.info("查询话题广场某分类下的话题");

        //业务处理
        List<TopicContent> list = new ArrayList() {
            {
                add(new TopicContent());
                add(new TopicContent());
                add(new TopicContent());
            }
        };

        //返回数据格式
//        MYPage<LaundryTopicContent> returnMsg = new MYPage<>(list);

        return WebResponse.successData(list);
    }

    /**
     * 查询话题的详情(postId)
     *
     * @return
     */
    @ApiOperation(value = "查询话题的详情", notes = "查询分类下的话题", httpMethod = "POST")
    @PostMapping("/findTopicDetailById")
    public WebResponse<TopicContent> findTopicDetailById(@RequestBody TopicContent topicDetailDto) {
        LOGGER.info("查询话题的详情" + topicDetailDto.getPostId());


        //业务处理
        TopicContent returnMsg = new TopicContent();

        return WebResponse.successData(returnMsg);
    }

    /**
     * 查看分享圈(pageNum、pageSize)
     *
     * @return
     */
    @ApiOperation(value = "查看分享圈", notes = "查看分享圈", httpMethod = "POST")
    @PostMapping("/findAllShare")
    public WebResponse findAll(@RequestBody BaseRequestParam requestParam) {
        LOGGER.info("查看分享圈");
        //开启分页
//        PageHelper.startPage(requestParamBody.getPageNumber(), requestParamBody.getPageSize());
        //业务处理
        List<TopicContent> returnMsg = new ArrayList<>();
        //返回数据格式
        return WebResponse.successData(returnMsg);
    }

    /**
     * 查看分享圈详情(shareId)
     */
    @ApiOperation(value = "查看分享圈详情", notes = "查看分享圈详情", httpMethod = "POST")
    @PostMapping("/shareDetail")
    public WebResponse shareDetail(@RequestBody TopicContent data) {
        LOGGER.info("查看分享圈详情");

        //返回数据格式
        return WebResponse.successData(new TopicContent());
    }

    /**
     * 用户发分享圈(userId, userCommentText, userCommentImg)
     *
     * @return
     */
    @ApiOperation(value = "用户发分享圈", notes = "用户发分享圈", httpMethod = "POST")
    @PostMapping("/addShare")
    public WebResponse addComment(@RequestBody TopicContent data) {
        LOGGER.info("用户发分享圈" + data);

        //返回数据格式
        return WebResponse.successData(1);
    }

    /**
     * 删除分享圈(userId、shareId)
     *
     * @return
     */
    @ApiOperation(value = "删除分享圈", notes = "删除分享圈", httpMethod = "POST")
    @PostMapping("/delShare")
    public WebResponse delComment(@RequestBody TopicContent userShare) {
        LOGGER.info("删除分享圈" + userShare);

        //返回数据格式
        return WebResponse.successData(1);
    }

    /**
     * 修改分享圈(userId、shareId)
     *
     * @return
     */
    @ApiOperation(value = "修改分享圈", notes = "修改分享圈", httpMethod = "POST")
    @PostMapping("/updShare")
    public WebResponse updComment(@RequestBody TopicContent userShare) {
        LOGGER.info("修改分享圈" + userShare);

        //返回数据格式
        return WebResponse.successData(1);
    }

}
